package com.cloud.utils;


import com.cloud.constant.SystemConstant;

public class ResultUtils {

    public static Result success(String msg, Object o){
        Result result=new Result();
        result.setSuccess(true);
        result.setCode(SystemConstant.SUCCESS_CODE);
        result.setMsg(msg);
        result.setData(o);
        return result;
    }
    public static Result success(String msg){
        Result result=new Result();
        result.setSuccess(true);
        result.setCode(SystemConstant.SUCCESS_CODE);
        result.setMsg(msg);
        return result;
    }
    public static Result error(Integer code,boolean success,String msg){
        Result result=new Result();
        result.setSuccess(success);
        result.setCode(code);
        result.setMsg(msg);
        result.setData(null);
        return result;
    }
    public static Result error(int code,String msg){
        Result result=new Result();
        result.setSuccess(false);
        result.setCode(code);
        result.setMsg(msg);
        result.setData(null);
        return result;
    }
    public static Result error(String msg){
        Result result=new Result();
        result.setSuccess(false);
        result.setCode(SystemConstant.FAILD_CODE);
        result.setMsg(msg);
        result.setData(null);
        return result;
    }
    public static Result unauthorized(String msg){
        Result result=new Result();
        result.setSuccess(false);
        result.setCode(SystemConstant.NO_PERMISSION);
        result.setMsg(msg);
        result.setData(null);
        return result;
    }
}
